string-cache
A string interning library for Rust, developed as part of the Servo project.
Simple usage
In Cargo.toml
:
[]
= "0.8"
In lib.rs
:
extern crate string_cache;
use DefaultAtom as Atom;
With static atoms
In Cargo.toml
:
[]
= "build.rs"
[]
= "0.8"
[]
= "0.5"
In build.rs
:
extern crate string_cache_codegen;
use env;
use Path;
In lib.rs
:
extern crate string_cache;
The generated code will define a FooAtom
type and a foo_atom!
macro.
The macro can be used in expression or patterns, with strings listed in build.rs
.
For example: